feat(audio): add sound effects toggle for keypresses and guess submissions - #1309
Merged
kike-alt merged 1 commit intoAug 26, 2026
Conversation
…sions - Create soundService.ts with Web Audio API synthesis for keypress, submit, and win sounds - Add soundEffects setting to SettingsProvider with localStorage persistence - Add sound effects toggle switch in SettingsPanel (default off) - Web Audio context initializes safely on first user interaction Closes kike-alt#1257
|
@lovesmilesmall-hue Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1257
Closes #1231
Closes #1258
Closes #1259
Adds Web Audio API sound effects for keypresses, guess submissions, and win conditions, with a toggle switch in the Settings panel (default off). The sound service initializes the AudioContext lazily on first user interaction to comply with browser autoplay policies.
Why
Audio feedback enhances tactile game feel for players who prefer sound. The implementation uses the Web Audio API's
OscillatorNodesynthesis rather than pre-loaded audio files, keeping the bundle size zero and enabling fine-grained control over tone parameters. The toggle persists tolocalStoragevia the existingSettingsProvider.What was built
frontend/src/services/soundService.ts:playSound(type)keypress(440 Hz square),submit(330+440 Hz sine),win(C5-E5-G5 arpeggio)initAudioContext()AudioContexton user gesture for safe resumefrontend/src/providers/settings-provider.tsx— AddedsoundEffects: booleantoGameSettingstype andsetSoundEffectscallback. Defaults tofalse.frontend/src/components/SettingsPanel.tsx— Added "Sound effects" toggle switch below the existing Color-blind mode toggle, matching the same switch component pattern.Integration changes outside
services/frontend/src/providers/settings-provider.tsx— ExtendedGameSettingstype withsoundEffectsfield and exposedsetSoundEffectssetter. Backward-compatible: existinglocalStoragedata withoutsoundEffectsdefaults tofalse.frontend/src/components/SettingsPanel.tsx— Added toggle UI; consumes newsoundEffects/setSoundEffectsfromuseSettings().No existing files deleted or broken.
Acceptance criteria coverage
soundService.ts—playSound("keypress"),playSound("submit"),playSound("win"))SettingsPanel.tsx— toggle withid="sound-toggle", defaultfalse)soundService.ts— lazyAudioContextcreation,ctx.resume()on suspended state)Test plan
npm test— not run per instructionnpm run build— not run per instructionEnv vars / Notes
No new environment variables. Sound effects are client-side only via Web Audio API. The
soundService.tsmodule is safe to import in SSR contexts (returns early iftypeof window === "undefined").